package com.um.springboot.starter.config;

import com.um.springboot.starter.properties.HshProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author 邓南辉
 * 日期 2019/12/7
 * 版权所有 广州优匠科技有限公司
 */
@Slf4j
@Component
public class SystemConfig {

    @Autowired
    HshProperties hshProperties;

    @PostConstruct
    public void loadAll(){
        try {

            //第1步：加载system_code.properties
            // log.info("第1步：加载system_code.properties");
            // SystemCode.getInstance().initSystemCode("app");

            //第2步：加载sql语句
            // log.info("第2步：加载sql语句");
            log.info("Initializing UM SQL");
            SystemSQL.getInstance().initSystemSQL("app");

            //第3步：加载验证器validators.xml
            // log.info("第3步：加载验证器validators.xml");
            // SystemValidator.getInstance().initValidators("app");

            //第4步：加载api的验证规则
            // log.info("第4步：加载api的验证规则");
            // SystemValidator.getInstance().initValidateRule("app");

        }catch (Exception ex){
            log.error("", ex);
        }
    }

    /**
     * 只加载系统错误编码
     */
    public void loadErrCode(){
        try {

            //第1步：加载system_code.properties
            // log.info("第1步：加载system_code.properties");
            // SystemCode.getInstance().initSystemCode("app");

        }catch (Exception ex){
            log.error("", ex);
        }
    }
}
